package com.leon.android.arch

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.core.view.postDelayed
import androidx.lifecycle.Observer
import com.jeremyliao.liveeventbus.LiveEventBus
import com.leon.android.common.event.BusEvent
import kotlinx.android.synthetic.main.activity_splash.*

class SplashActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)
        if (!MainApp.app.isInit){
            LiveEventBus.get(BusEvent.APP_INIT_COMPLETED).observe(this, Observer {
                MainApp.app.isInit = true
                logoIv.postDelayed(3000){
                    NavigationHelper.goMainActivity()
                    finish()
                }
            })
        } else {
            logoIv.postDelayed(3000){
                NavigationHelper.goMainActivity()
                finish()
            }
        }
    }
}
